from google.appengine.ext import db
from google.appengine.api import images
from google.appengine.ext.db import djangoforms

#DB Models
class Member(db.Model):
    name = db.StringProperty()
    salt = db.StringProperty()
    password = db.StringProperty()
    fullname = db.StringProperty()
    email = db.StringProperty()
    emailisvalid = db.BooleanProperty()
    emailvalidationcode = db.StringProperty()
    timeadded = db.DateTimeProperty(auto_now_add=True)
    group = db.StringProperty(required=True,
            default="guest",
            choices=set(["guest","scout","parent","admin","dev"]))
    
class LoginRecord(db.Model):
    code = db.StringProperty()
    member = db.ReferenceProperty(Member)
    timeadded = db.DateTimeProperty(auto_now_add=True)
    browser = db.StringProperty()
    ip = db.StringProperty()

class Photo(db.Model):
    member = db.ReferenceProperty(Member)
    filename = db.StringProperty()
    content = db.BlobProperty()
    thumb = db.BlobProperty()
    timeadded = db.DateTimeProperty(auto_now_add=True)
    
class PasswordResetLink(db.Model):
    member = db.ReferenceProperty(Member)
    code = db.StringProperty()
    alreadyused = db.BooleanProperty()
    timeadded = db.DateTimeProperty(auto_now_add=True)

class Announcement(db.Model):
    member = db.ReferenceProperty(Member)
    subject = db.StringProperty()
    priority = db.StringProperty(default='Medium', choices = ['High','Medium','Low'])
    expiration = db.DateTimeProperty()
    timeadded = db.DateTimeProperty(auto_now_add=True)
    body = db.Text()
#End of DB Models

# Django model forms
class AnnouncementForm(djangoforms.ModelForm):
    class Meta:
        model=Announcement
        exclude = ['member','timeadded']

# End of Django model forms
